local skel = fk.CreateSkill {
  name = "emo__wangqing",
}

Fk:loadTranslationTable{
  ["emo__wangqing"] = "忘情",
  [":emo__wangqing"] = "每回合限两次，每当你受到其他角色造成的伤害后，你可以与该角色各摸一张牌，然后其可以令你对其造成伤害，并令你选一项：1.交给其两张手牌；2.回复一点体力。",

  ["#emo__wangqing-ask"] = "忘情：你可与 %src 各摸1张牌",
  ["#emo__wangqing-damage"] = "忘情：你可以令 %src 对你造成1点伤害！",
  ["#emo__wangqing-give"] = "忘情：你需交给 %src 两张手牌，否则你回复一点体力",
}

skel:addEffect(fk.Damaged, {
  anim_type = "masochism",
  times = function (self, player)
    return 2 - player:usedSkillTimes(skel.name)
  end,
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and target == player and data.from and not data.from.dead and data.from ~= player
    and player:usedSkillTimes(skel.name) < 2
  end,
  on_cost = function(self, event, target, player, data)
    if player.room:askToSkillInvoke(player, { skill_name = skel.name, prompt =  "#emo__wangqing-ask:"..data.from.id}) then
      event:setCostData(self, { tos = {data.from} })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(1, skel.name)
    local to = data.from
    if not to or to.dead then return end
    to:drawCards(1, skel.name)
    local room = player.room
    if not player.dead and not to.dead then
      if room:askToSkillInvoke(to, { skill_name = skel.name, prompt = "#emo__wangqing-damage:"..player.id }) then
        room:doIndicate( player, {to} )
        room:damage{ from = player, to = to, damage = 1 }
        if player.dead then return end
        if not to.dead and player:getHandcardNum() > 1 then
          local give = room:askToCards(player, {
            min_num = 2, max_num = 2, include_equip = false, cancelable = true, skill_name = skel.name,
            prompt = "#emo__wangqing-give:"..to.id
          })
          if #give == 2 then
            room:obtainCard(to, give, false, fk.ReasonGive, player, skel.name)
            return
          end
        end
        room:recover { num = 1, skillName = skel.name, who = player, recoverBy = player }
      end
    end
  end,
})

return skel
